#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int isSubstring(char* s, char* t) {
    int slen = strlen(s);
    int tlen = strlen(t);
    if (slen == 0) return 1;
    int sidx = 0;
    int tidx = 0;
    int mlen = 0;
    while(t[tidx] != '\0' && tlen - tidx >= slen) {
        printf("t[i] = %d, s[i] = %d\n", t[tidx], s[sidx]);
        while(s[sidx] != '\0') {
            if ((int) (t[tidx + sidx] - s[sidx]) == 0) {
                mlen++;
                sidx++;
                if (mlen == slen) return 1;
            } else {
                mlen = 0;
                sidx = 0;
                break;
            }
        }
        sidx = 0;
        tidx++;
    }
    return 0;
}

int main() {
    char *s = "ad";
    char *t = "abcd";
    int res = isSubstring(s, t);
    printf("res = %d\n", res);
    return 0;
}